<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>

</body>
<script>
    var num = prompt('请输入班级的总人数'); //总的班级人数
    var sum = 0; //求和的变量
    var average = 0; //求平均值的变量
    for (var i = 1; i <= num; i++) {
        var score = prompt('请您输入第' + i + '个学生成绩');
        //因为从prompt取过来的数据是 字符串型的需要转换为数字型
        sum = sum + parseFloat(score);
    }
    average = sum / num;
    alert('班级总的成绩是' + sum);
    alert('班级平均分是' + average);
</script>

</html>